#include maps\_utility;
#include common_scripts\utility;
#include maps\_weather;

main()
{
	disableFX = false;

	disable_fx = GetDvarInt( "disable_fx" );
	if( IsDefined( disable_fx ) && disable_fx > 0 )
	{
		disableFX = true;
	}

	if( !disableFX )
	{
		scripted_fx();
		//thread water_drops_init();
	}

	maps\createart\camp_assault_art::main();
	maps\createfx\camp_assault_fx::main();
	wind_settings();

	footsteps();
	precache_createfx_fx();

	level._effect["lightning_strike"] = LoadFX( "maps/ber2/fx_ber2_lightning_flash" );
	level._effect["rain_10"]	= LoadFX( "env/weather/fx_rain_sys_heavy" );
	level._effect["rain_9"]		= LoadFX( "env/weather/fx_rain_sys_heavy" );
	level._effect["rain_8"]		= LoadFX( "env/weather/fx_rain_sys_heavy" );
	level._effect["rain_7"]		= LoadFX( "env/weather/fx_rain_sys_heavy" );
	level._effect["rain_6"]		= LoadFX( "env/weather/fx_rain_sys_med" );
	level._effect["rain_5"]		= LoadFX( "env/weather/fx_rain_sys_med" );
	level._effect["rain_4"]		= LoadFX( "env/weather/fx_rain_sys_med" );
	level._effect["rain_3"]		= LoadFX( "env/weather/fx_rain_sys_med" );
	level._effect["rain_2"]		= LoadFX( "env/weather/fx_rain_sys_lght" );
	level._effect["rain_1"]		= LoadFX( "env/weather/fx_rain_sys_lght" );
	level._effect["rain_0"]		= LoadFX( "env/weather/fx_rain_sys_lght" );

	thread weather_control( disableFX );
}

footsteps()
{
	animscripts\utility::setFootstepEffect( "asphalt",    LoadFx( "bio/player/fx_footstep_dust" ) );
	animscripts\utility::setFootstepEffect( "brick",      LoadFx( "bio/player/fx_footstep_dust" ) );
	animscripts\utility::setFootstepEffect( "carpet",     LoadFx( "bio/player/fx_footstep_dust" ) );
	animscripts\utility::setFootstepEffect( "cloth",      LoadFx( "bio/player/fx_footstep_dust" ) );
	animscripts\utility::setFootstepEffect( "concrete",   LoadFx( "bio/player/fx_footstep_dust" ) );
	animscripts\utility::setFootstepEffect( "dirt",       LoadFx( "bio/player/fx_footstep_sand" ) );
	animscripts\utility::setFootstepEffect( "foliage",    LoadFx( "bio/player/fx_footstep_dust" ) );
	animscripts\utility::setFootstepEffect( "gravel",     LoadFx( "bio/player/fx_footstep_sand" ) );
	animscripts\utility::setFootstepEffect( "grass",      LoadFx( "bio/player/fx_footstep_sand" ) );
	animscripts\utility::setFootstepEffect( "ice",        LoadFx( "bio/player/fx_footstep_snow" ) );
	animscripts\utility::setFootstepEffect( "metal",      LoadFx( "bio/player/fx_footstep_dust" ) );
	animscripts\utility::setFootstepEffect( "mud",        LoadFx( "bio/player/fx_footstep_mud" ) );
	animscripts\utility::setFootstepEffect( "paper",      LoadFx( "bio/player/fx_footstep_dust" ) );
	animscripts\utility::setFootstepEffect( "plaster",    LoadFx( "bio/player/fx_footstep_dust" ) );
	animscripts\utility::setFootstepEffect( "rock",       LoadFx( "bio/player/fx_footstep_sand" ) );
	animscripts\utility::setFootstepEffect( "sand",       LoadFx( "bio/player/fx_footstep_sand" ) );
	animscripts\utility::setFootstepEffect( "snow",       LoadFx( "bio/player/fx_footstep_snow" ) );
	animscripts\utility::setFootstepEffect( "water",      LoadFx( "bio/player/fx_footstep_water" ) );
	animscripts\utility::setFootstepEffect( "wood",       LoadFx( "bio/player/fx_footstep_dust" ) );
}

weather_control( disableFX )
{
	if( IsDefined( disableFX ) && disableFX )
	{
		disableFX = true;
	}
	else
	{
		disableFX = false;
	}
	
	rainInit( "hard" );
	level thread rainEffectChange( 9, 0.1 );
	thread playerWeather();
	
	if( !disableFX )
	{
		addLightningExploder( 10001 );
		addLightningExploder( 10002 );
		addLightningExploder( 10003 );
		addLightningExploder( 10004 );
		addLightningExploder( 10005 );
	}
	
//	if( !disableFX )
//	{
//		level.thunderSoundEmitter = getent_safe( "thunder_struct", "targetname" );
//	}
	
	level.nextLightning = GetTime() + 1;
	thread lightning( ::lightning_normal, ::lightning_flash );
}

lightning_flash()
{
	// Done On Client Side
}

lightning_normal()
{
	// Done On Client Side
}

view_settings()
{
	SetSavedDvar( "r_motionblur_enable", 1 );
	SetSavedDvar( "r_motionblur_positionFactor", 0.17 );
	SetSavedDvar( "r_motionblur_directionFactor", 0.17 );
}

wind_settings()
{
	SetSavedDvar( "wind_global_vector", "162 59 7.5" );
	SetSavedDvar( "wind_global_low_altitude", 19 );
	SetSavedDvar( "wind_global_hi_altitude", 561 );
	SetSavedDvar( "wind_global_low_strength_percent", 0.07 );
}

water_settings()
{
	SetDvar( "r_watersim_curlAmount", 		1 );
	SetDvar( "r_watersim_curlMax", 			1 );
	SetDvar( "r_watersim_curlReduce", 		0.95 );
	SetDvar( "r_watersim_minShoreHeight", 	-3.2 );
	SetDvar( "r_watersim_waveSeedDelay", 	250.0 );
	SetDvar( "r_watersim_foamAppear", 		20 );
	SetDvar( "r_watersim_foamDisappear", 	0.775 );
	SetDvar( "r_watersim_windAmount", 		0.4 );
	SetDvar( "r_watersim_windMax", 			0.21 );
	SetDvar( "r_watersim_windDir", 			340.0 );
	waittillframeend;
	WaterSimEnable( true );
}

scripted_fx()
{
	level._effect["truck_headlights"]					   		  = LoadFX("env/light/fx_ray_headlight_truck");

	level._effect["rifleflash"] = LoadFX( "weapon/muzzleflashes/standardflashworld" );
	level._effect["rifle_shelleject"] = LoadFX( "weapon/shellejects/rifle" );
	level._effect["headshot"] = LoadFX( "maps/ber2/fx_deathfx_headshot_ber2" );
	level._effect["bloodspurt"] = LoadFX( "maps/ber2/fx_deathfx_head_bloodspurt_ber2" );
}

precache_createfx_fx()
{
	level._effect["flesh_hit"] 						= LoadFX( "impacts/flesh_hit_body_fatal_exit" );

	level._effect["insects_lantern1"] = LoadFX( "bio/insects/fx_insects_lantern_1" );
	level._effect["insects_lantern2"] = LoadFX( "bio/insects/fx_insects_lantern_2" );
	level._effect["campfire_smolder"] = LoadFX( "env/fire/fx_fire_campfire_smolder" );
	level._effect["campfire_medium"] = LoadFX( "maps/mak/fx_fire_camp_med" );
	level._effect["chimney_smoke"] = LoadFX( "maps/mak/fx_smoke_chimney_med" );
	level._effect["chimney_smoke_large"] = LoadFX( "env/smoke/fx_smoke_wood_chimney_lrg" );
	level._effect["searchlight_1"] = LoadFX( "misc/fx_spotlight_large" );
	level._effect["bats_circling"] = LoadFX( "bio/animals/fx_bats_circling" );
	level._effect["bats_swarm"] = LoadFX( "bio/animals/fx_bats_circling_swarm" );
	level._effect["floor_rays_large"] = LoadFX( "maps/mak/fx_ray_linear_large" );
	level._effect["floor_rays_medium"] = LoadFX( "maps/mak/fx_ray_linear_med" );
	level._effect["plume_collapse_dust"] = LoadFX( "explosions/fx_dust_cloud_plume_1" );
	level._effect["mist_rolling"] = LoadFX( "maps/mak/fx_fog_rolling_thin" );
	level._effect["mist_rolling2"] = LoadFX( "maps/mak/fx_fog_rolling_thin2" );
	level._effect["fire_barrel_medium"] = LoadFX( "env/fire/fx_fire_barrel_med" );
	level._effect["fire_barrel_small"] = LoadFX( "env/fire/fx_fire_barrel_small" );
	level._effect["glow_outdoor"] = LoadFX( "env/light/fx_glow_lampost_white_dim_static" );
	level._effect["glow_indoor"] = LoadFX( "env/light/fx_light_indoor_white_static" );
	level._effect["insects_swarm"] = LoadFX( "maps/mak/fx_insects_swarm" );
	level._effect["glow_spotlight"] = LoadFX( "env/light/fx_glow_spotlight_white_dim_static" );
	level._effect["sys_e_smoke_trail"] = LoadFX( "maps/mak/fx_sys_element_smoke_tail_small" );
	level._effect["fire_debris_small"] = LoadFX( "maps/mak/fx_fire_debris_small" );
	level._effect["fire_debris_med"] = LoadFX( "maps/mak/fx_fire_debris_med" );
	level._effect["fire_debris_large"] = LoadFX( "maps/mak/fx_fire_debris_large" );
	level._effect["fire_debris_large_direct"] = LoadFX( "maps/mak/fx_fire_debris_large_directional" );
	level._effect["glow_indoor_spot"] = LoadFX( "maps/mak/fx_light_glow_lantern_spot" );
	level._effect["fire_debris_large_single"] = LoadFX( "maps/mak/fx_fire_debris_large_single" );
	level._effect["fire_debris_ash_cloud"] = LoadFX( "maps/mak/fx_fire_debris_ash_cloud" );
	level._effect["fire_embers_patch"] = LoadFX( "maps/mak/fx_fire_debris_embers_patch" );
	level._effect["fire_embers_patch2"] = LoadFX( "maps/mak/fx_fire_debris_embers_patch2" );
	level._effect["fire_debris_med_line"] = LoadFX( "maps/mak/fx_fire_debris_med_line" );
	level._effect["fire_debris_med_line2"] = LoadFX( "maps/mak/fx_fire_debris_med_line2" );
	level._effect["fire_debris_med_line3"] = LoadFX( "maps/mak/fx_fire_debris_med_line3" );
	level._effect["fire_water_medium"] = LoadFX( "maps/mak/fx_fire_water_med" );
	level._effect["fire_water_small"] = LoadFX( "maps/mak/fx_fire_water_small" );
	level._effect["fire_smoke_column1"] = LoadFX( "maps/mak/fx_smoke_column" );
	level._effect["fire_smoke_column2"] = LoadFX( "maps/mak/fx_smoke_column2" );
	level._effect["fire_hut_d_light"] = LoadFX( "maps/mak/fx_fire_hut_d_light" );
	level._effect["god_ray_moon1"] = LoadFX( "maps/mak/fx_ray_linear_large_moon" );
	level._effect["god_ray_moon2"] = LoadFX( "maps/mak/fx_ray_linear_large_moon2" );
	level._effect["god_ray_moon3"] = LoadFX( "maps/mak/fx_ray_linear_large_moon3" );
	level._effect["god_ray_moon4"] = LoadFX( "maps/mak/fx_ray_linear_large_moon4" );
	level._effect["god_ray_fire"] = LoadFX( "maps/mak/fx_ray_linear_fire_small" );
	level._effect["god_ray_fire2"] = LoadFX( "maps/mak/fx_ray_linear_fire_medium" );
	level._effect["smoke_ambiance_indoor"] = LoadFX( "maps/mak/fx_smoke_ambiance_indoor" );
	level._effect["water_flow"] = LoadFX( "maps/mak/fx_water_wake_flow" );
	level._effect["water_splash_rocks"] = LoadFX( "maps/mak/fx_water_splash_rocks" );
	level._effect["water_wake_mist"] = LoadFX( "maps/mak/fx_water_wake_mist" );
	level._effect["water_wake_ripples"] = LoadFX( "maps/mak/fx_water_ripples_small" );
	level._effect["glow_candle"] = LoadFX( "env/light/fx_dlight_candle_glow" );
	level._effect["lantern_on_global"]	= LoadFX( "env/light/fx_lights_lantern_on" );
}